module.exports = function ($scope, $resource, $modalInstance, toaster) {

    $scope.bean = {};

    //保存
    $scope.ok = function () {
        if (!$scope.bean.company_code) {
            toaster.warning({ title: '', body: '请填写机构编号' });
            return false;
        }
        $resource('/api/ac/mc/merchantUserAccountService/createAccountByCompanyCode', {}, {}).save($scope.bean, function (res) {
            if (res.errcode === 0) {
                toaster.success({ title: '', body: '操作成功' });
                $modalInstance.close($scope.bean.company_code);
            } else {
                toaster.error({ title: '', body: res.errmsg });
            }
        });
    }

    //取消
    $scope.close = function () {
        $modalInstance.dismiss('cancel');
    }

};